<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

</head><body>
<%@include file="../include/header.jsp" %>

<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <input type="hidden" id="endTime" value="<fmt:formatDate value='${activity.endTime}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
        <div class="section-main">
            <%--众筹主题--->直接付款--%>
            <div class="layui-tab layui-tab-brief mt20" lay-filter="type">
                <ul class="layui-tab-title">
                    <li class="" id="funding">众筹<span id="total_1" class="pl5">${projectNum}</span>人</li>
                    <li class="" id="representing">联合发起<span id="total_0" class="pl5">${representNum}</span>人</li>
                    <li class="layui-this" id="directPay">直接付款<span id="total_2" class="pl5">${directPayNum}</span>人</li>
                </ul>
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/crowdfund/project/dpListForEvent.do?eventId=${projectWithAuthor.eventId}" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label class="search-form-lable">姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorName" autocomplete="off"
                                                   class="layui-input" value="${projectWithAuthor.authorName}"
                                                   placeholder="姓名">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorMobile" autocomplete="off"
                                                   class="layui-input" value="${projectWithAuthor.authorMobile}"
                                                   placeholder="联系电话">
                                        </div>
                                    </li>

                                    <li class="form-item">
                                        <label class="search-form-lable">支付状态</label>
                                        <div class="layui-input-inline">
                                            <select name="isSuccess">
                                                <option value="">全部</option>
                                                <option value="0" ${projectWithAuthor.isSuccess == 0 ? 'selected="selected"' : ''}>未支付</option>
                                                <option value="1" ${projectWithAuthor.isSuccess == 1 ? 'selected="selected"' : ''}>支付成功</option>
                                                <option value="3" ${projectWithAuthor.isSuccess == 3 ? 'selected="selected"' : ''}>退款中</option>
                                                <option value="4" ${projectWithAuthor.isSuccess == 4 ? 'selected="selected"' : ''}>退款成功</option>
                                                <option value="5" ${projectWithAuthor.isSuccess == 5 ? 'selected="selected"' : ''}>退款失败</option>
                                            </select>
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <form class="layui-form" action="${ctx}/crowdfund/project/dpListForEventExport.do?eventId=${projectWithAuthor.eventId}" id="exportForm" method="post">
                    </form>
                    <div class="my-act-list-content">
                        <ul class="num">
                            <div class="l">
                                <li class="f16">众筹人数<span class="red">${page.totalCount}</span>人</li>
                                <li class="f16">总金额
                                    <span class="red">
                                        <c:if test="${totalMoney > 0}">
                                            <fmt:formatNumber pattern="#,###.##" value="${totalMoney}"/>
                                        </c:if>
                                        <c:if test="${totalMoney == 0.0}">
                                            ${totalMoney}
                                        </c:if>
                                    </span> 元
                                </li>
                                <li class="f16">退款金额
                                    <span class="red">
                                        <c:if test="${refundMoney > 0}">
                                            <fmt:formatNumber pattern="#,###.##" value="${refundMoney}"/>
                                        </c:if>
                                        <c:if test="${refundMoney == 0.0}">
                                            ${refundMoney}
                                        </c:if>
                                    </span> 元
                                </li>
                                <li class="f16">剩余金额
                                    <span class="red">
                                        <c:if test="${remainMoney > 0}">
                                            <fmt:formatNumber pattern="#,###.##" value="${remainMoney}"/>
                                        </c:if>
                                        <c:if test="${remainMoney == 0.0}">
                                            ${remainMoney}
                                        </c:if>
                                    </span> 元
                                </li>
                            </div>
                            <div class="r">
                                <li style="cursor: pointer;" class="r">
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                </li>
                            </div>
                            <p class="cl"></p>
                        </ul>
                        <div class="cl">
                            <table class="layui-table">
                                <colgroup>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>姓名</th>
                                    <th>公司</th>
                                    <th>区域</th>
                                    <th>职务</th>
                                    <th>联系电话</th>
                                    <th>付款金额</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="directPay" items="${list}">
                                    <tr>
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.authorId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${directPay.authorLogo != null}">${directPay.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue"
                                                                                       title="${directPay.authorName}"
                                                                                       href="javascript:void(0);">${directPay.authorName}</a>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="dib ellipsis-1"
                                                 title="${directPay.authorCompany}">${directPay.authorCompany}</div>
                                        </td>
                                        <td>
                                                ${directPay.cityName}
                                        </td>
                                        <td>
                                                ${directPay.authorJobTitle}
                                        </td>
                                        <td>
                                                ${directPay.authorMobile}
                                        </td>

                                        <td>
                                            <a href="javascript:void(0);"
                                               class="blue ${directPay.actualAmount > 0||directPay.isSuccess == 4 ? 'actualAmount' : ''} count-num"
                                               data-id="${directPay.id}"
                                               data-name="${directPay.authorName}"> ${directPay.actualAmount}</a>
                                        </td>
                                        <td>
                                            <c:choose>
                                                <c:when test="${directPay.isSuccess==0}">未支付</c:when>
                                                <c:when test="${directPay.isSuccess==1}">支付成功</c:when>
                                                <c:when test="${directPay.isSuccess==3}">退款中</c:when>
                                                <c:when test="${directPay.isSuccess==4}">退款成功</c:when>
                                                <c:when test="${directPay.isSuccess==5}">退款失败</c:when>
                                            </c:choose>
                                        </td>
                                        <td class="tb-opts">
                                            <div class="comm-opts">
                                            <a href="javascript:openDialogShow('数据查看','${ctx}/crowdfund/support/chartView.do?projectId=${directPay.id}&eventId=${projectWithAuthor.eventId}','1050px','500px')"
                                               target="_self">
                                                数据查看
                                            </a>
                                            <a class="qr-btn" href="javascript:txz.openQrDialog({
                                                            title:'扫码二维码可预览分享',
                                                            detailList:[
                                                               {
                                                               title:'直接付款众筹详情',
                                                               url:'${directPay.qrCodeUrl}',
                                                               link: '${directPay.url}'
                                                               }
                                                            ]
                                                            })"> 二维码</a>
                                            <%--<c:if test="${directPay.actualAmount > 0
                                                    && (directPay.isSuccess == 1 || directPay.isSuccess == 5)}">
                                                <a href="javascript:refund('${directPay.supportId}');"
                                                   target="_self">退款</a>
                                            </c:if><a href="javascript:revise('${directPay.id}')"
                                                      target="_self">校正</a>--%>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '众筹主题',
            href: '${ctx}/crowdfund/event/list.do',
        }, {
            name: '${crowdfundEvent.name}'
        }, {
            name: '数据查看',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['element'], function () {
            var element = layui.element;

            element.on('tab', function (data) {
                if (data.index == 0) {
                    window.location.href = "${ctx}/crowdfund/project/listForEvent.do?eventId=${projectWithAuthor.eventId}";
                }
                else if (data.index == 1) {
                    window.location.href = "${ctx}/crowdfund/represen/listForEvent.do?eventId=${projectWithAuthor.eventId}";
                } else if (data.index == 2) {//直接付款众筹
                    window.location.href = "${ctx}/crowdfund/project/dpListForEvent.do?eventId=${projectWithAuthor.eventId}";
                }
            });

            element.on('tab(zc)', function (data) {
                if (data.index == 0) {
                    $('#isSuccess').val('');
                    $('#myForm').submit();
                }
                else if (data.index == 1) {
                    $('#isSuccess').val('0');
                    $('#myForm').submit();
                }
                else if (data.index == 2) {
                    $('#isSuccess').val('1');
                    $('#myForm').submit();
                }
                else if (data.index == 3) {
                    $('#isSuccess').val('3');
                    $('#myForm').submit();
                }
                else if (data.index == 4) {
                    $('#isSuccess').val('4');
                    $('#myForm').submit();
                }
            });
        });
        $('.childNum').click(function () {
            var id = this.dataset.id;
            openDialogShow('下级报名人数', '${ctx}/crowdfund/project/childList.do?id=' + id, '800px', '500px')
        });

        $('.favorerNum').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/event/listForProjectId.do?eventId=${projectWithAuthor.eventId}&projectId=' + projectId;
        });

        $('.actualAmount').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/event/dpListForProjectId.do?eventId=${projectWithAuthor.eventId}&projectId=' + projectId;
        });
    });

    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var url = $("#exportForm").attr('action');
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post(url, $("#myForm").serialize(), function (res) {
                top.layer.close(loadIndex);
                if (res.success) {
                    window.location.href = res.data;
                } else {
                    util.layerMsgError(res.description)
                }
            });
            top.layer.close(index);
        });
    }
</script>
</body>
</html>
